//package com.dykj.fireFighting.web.mq.consumer.business;
//
//import com.alibaba.fastjson.JSON;
//import com.dykj.fireFighting.api.elasticsearch.devHis.entity.EsDevHis;
//import com.dykj.fireFighting.api.elasticsearch.devHis.service.EsDevHisService;
//import com.dykj.fireFighting.common.starter.redisson.service.RedisService;
//import com.dykj.fireFighting.web.model.report.DevHis;
//import com.dykj.fireFighting.web.service.DevHisService;
//import com.dykj.fireFighting.web.utils.BeanContext;
//import com.dykj.fireFighting.web.utils.SpringUtil;
//import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
//import org.apache.rocketmq.common.message.Message;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.BeanUtils;
//
//
//import java.io.UnsupportedEncodingException;
//
//
///**
// * @Author fgc
// * @Date 2021/9/30 10:12
// * @ Description：MQ消息业务处理--设备运行记录入库
// */
//public class InsertDevHis extends BusinessProcess{
//    public static final Logger LOGGER = LoggerFactory.getLogger(InsertDevHis.class);
//    private static RedisService redisService=(RedisService) SpringUtil.getBean(RedisService.class);
//    private static DevHisService devHisService=(DevHisService) SpringUtil.getBean(DevHisService.class);
//    private static EsDevHisService esDevHisService=(EsDevHisService)SpringUtil.getBean("esDevHisService");
//    public InsertDevHis(){
//        super();
//    }
//    @Override
//    public ConsumeConcurrentlyStatus process(Message msg){
//        LOGGER.info("进入插入设备运行记录业务实现");
//        String msgBody= null;
//        try {
//            msgBody = new String (msg.getBody(),"utf-8");
//            DevHis devHis = JSON.parseObject(msgBody, DevHis.class);
//            LOGGER.info("===========插入devHis数据到mysql==============");
//            devHisService.insertHis(devHis);
//            LOGGER.info("===========插入EsDevHis数据到ES==============");
//            EsDevHis esDevHis = new EsDevHis();
//            BeanUtils.copyProperties(devHis, esDevHis);
//            esDevHis.setUnitId(devHis.getUnitsCode());
//            esDevHis.setDeviceName(devHis.getDevName());
//            esDevHis = esDevHisService.importAll(esDevHis);
//            LOGGER.info("===========插入EsDevHis数据到ES:=============" + JSON.toJSONString(esDevHis));
//
//            redisService.set(devHis.getId(), JSON.toJSONString(devHis), 3600l);
//            return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
//        } catch (UnsupportedEncodingException e) {
//            e.printStackTrace();
//            return ConsumeConcurrentlyStatus.RECONSUME_LATER;
//        }
//
//    }
//
//}
